﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using ZLCMS.Business.Util;
using ZLCMS.Data.Model;
using NHibernate;
using DotNet.Common.NHibernateUtil;
using NHibernate.Criterion;
namespace ZLCMS.Web.ShopCart
{
    public partial class ShopCartMaster : System.Web.UI.MasterPage
    {
        public MemberInfo _memberInfo;

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        public MemberInfo LoadMember()
        {
            string account = UserKit.GetUserAccountWithoutException();

            if (account == null)
            {
                Response.Redirect("/MemberUser/Login.aspx");
            }

            try
            {
                using (ISession session = SessionFactoryHelper.CreateSession())
                {
                    _memberInfo = session.CreateCriteria<MemberInfo>().Add(Expression.Eq("AccountId",account)).UniqueResult<MemberInfo>();
                }
            }
            catch
            {
                Response.Redirect("/MemberUser/Login.aspx");
            }

            if (_memberInfo == null)
            {
                Response.Redirect("/MemberUser/Login.aspx");
            }

            return _memberInfo;
        }
    }
}
